package com.ruofeng.app.kotlin.common.dsl

import org.junit.Test
import java.io.File
import java.net.URL

/**
 * Created by 邱鹏 on 2017/8/25.
 */
open class StringExtends {
    inline operator fun String.invoke(block: (URL) -> Unit) {
        block(URL(this))
    }

    @Test
    fun testStringExtends() {
        "http://www.baidu.com" { url ->
            File("download.html").run {
                if (!exists()) {
                    createNewFile()
                }
                writeText(url.readText())
            }
        }
    }

}